(function (aopc) {
    aopc.addExpandPage(827, function (get) {
        return {
            expandInit() {
                const meetingStatus = this.getProperty('TimeStatus3');
                meetingStatus.isCondition = true;
                meetingStatus.getValue = () => meetingStatus.value || 0;
                const [p1, p2] = meetingStatus.properties;
                p1.eventActionName = 'onCurrentMeeting';
                p2.eventActionName = 'onHistoryMeeting';
                this.meetingStatus = meetingStatus;
            },
            setInit() {
                this.pageData.MeetingRoomId = this.visitUser.MeetingRoomId;
            },
            expandSetData({ rowData }) {
                const { data } = rowData;
                if (!this.getIsHost()) {
                    data.IsTemplate2 = 0;
                    data.TimeStatus1 = 0;
                    data.TimeStatus2 = 0;
                    data.Edit2 = 0;
                    data.IsDelete2 = 0;
                }
            },
            deleteMeeting({ property }) {
                if (property.isLoading) return;
                const { data } = property.rowData;
                const { MeetingId, RowVersion } = data;

                if (property.isLoading) return;
                this.confirm('确定要删除当前会议吗', () => {
                    const { serviceInterface } = property;
                    const { serviceName, actionName } = serviceInterface;

                    const payload = { pathQuery: `(${MeetingId})?RowVersion=${RowVersion}` }

                    property.isLoading = true;
                    this.dispatchAction(serviceName, actionName, payload).then(res => {
                        property.isLoading = false;
                        if (res.isSuccess !== false) {
                            this.alertSuccess('删除成功！', () => {
                                data._isDelete = 1;
                                const row_view = property.getView().getView().getView();
                                row_view.setIsVisible(false);
                            });
                        }
                    });
                });
            },
            toMeetingEdit({ property }) {
                const { MeetingId, IsBook } = property.rowData.data;
                let pageName = IsBook ? 'bookMeetingEdit.html' : 'quickMeeting.html';
                const backUrl = encodeURIComponent("/myMeeting.html");
                this.toPage(`/${pageName}?MeetingId=${MeetingId}&backUrl=${backUrl}`);
            },
            onCurrentMeeting(props) {
                if (this.meetingStatus.getValue() === 0) return;
                this.meetingStatus.value = 0;
                this.setStatusStyle(props);
            },
            onHistoryMeeting(props) {
                if (this.meetingStatus.getValue() === 1) return;
                this.meetingStatus.value = 1;
                this.setStatusStyle(props);
            },
            setStatusStyle(props) {
                const v = this.meetingStatus.getValue();
                const [p1, p2] = this.meetingStatus.properties;
                p1.spanStyle.color = v === 0 ? '#ffffff' : '#badcf3';
                p1.refresh();
                p2.spanStyle.color = v === 1 ? '#ffffff' : '#badcf3';
                p2.refresh();

                this.invokeEventAction('searchQuery', props);
            },
            successEndCallback({ property }) {
                const { data } = property.rowData;
                const { MeetingId } = data
                this.webSocket.send('endMeeting', { MeetingId });
            }
        }
    });
})(window.aopc);